<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>AurebeshRuneTest</title>

<link rel="stylesheet"
	href="http://code.jquery.com/qunit/qunit-1.15.0.css">
<script src="http://code.jquery.com/qunit/qunit-1.15.0.js"></script>

<script src="../../main/js/util/Logger.js"></script>
<script src="../../main/js/util/ArrayAugments.js"></script>

<script src="../../main/js/AurebeshRune.js"></script>

<script>
    var LOGGER = new Logger();

    QUnit.test("findRuneByPhoneme",
            function(assert)
            {
                assert.equal(AurebeshRune.findRuneByPhoneme("t"),
                        AurebeshRune.TRILL);
                assert.equal(AurebeshRune.findRuneByPhoneme("p"),
                        AurebeshRune.PETH);
                assert.equal(AurebeshRune.findRuneByPhoneme("ch"),
                        AurebeshRune.CHEREK);
                assert.equal(AurebeshRune.findRuneByPhoneme("k"),
                        AurebeshRune.KRILL);

                assert.equal(AurebeshRune.findRuneByPhoneme("r"),
                        AurebeshRune.RESH);
                assert.equal(AurebeshRune.findRuneByPhoneme("w"),
                        AurebeshRune.WESK);
                assert.equal(AurebeshRune.findRuneByPhoneme("y"),
                        AurebeshRune.YIRT);

                assert.equal(AurebeshRune.findRuneByPhoneme("h"),
                        AurebeshRune.HERF);
                assert.equal(AurebeshRune.findRuneByPhoneme("w"),
                        AurebeshRune.WESK);
                assert.equal(AurebeshRune.findRuneByPhoneme("i"),
                        AurebeshRune.ISK);
                assert.equal(AurebeshRune.findRuneByPhoneme("u"),
                        AurebeshRune.USK);
            });

    QUnit.test("values", function(assert)
    {
        var keysLength = Object.keys(AurebeshRune).length - 1 // properties
        - 1 // values
        - 1 // findRuneByPhoneme
        ;

        var properties = Object.getOwnPropertyNames(AurebeshRune);

        for (var i = 0; i < properties.length; i++)
        {
            var property = properties[i];

            if (property === "properties" || property === "values"
                    || property === "findRuneByPhoneme")
            {
                continue;
            }

            var key = AurebeshRune[property];

            if (!AurebeshRune.values.contains(key))
            {
                LOGGER.error("missing value for property " + property + " key "
                        + key);
            }
        }

        assert.equal(AurebeshRune.values.length, keysLength);
    });
</script>
</head>
<body>
	<div id="qunit"></div>
</body>
</html>
